#!/usr/bin/ruby
# -*- ruby -*-
#
# http://programmingpraxis.com/2013/02/01/hofstadters-sequence/

require 'set'

n = ARGV.first.to_i || 5

last = 1
used = Set.new([last])
incr  = 2

n.times do
    last = last + incr

    used << last

    incr = incr + 1

    while used.include?(incr)
        incr = incr + 1
    end
end

puts used.to_a.sort.join(" ")
